package org.sws.domain.behavior.strategy.impl;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.sws.domain.activity.model.entity.SkuRechargeEntity;
import org.sws.domain.activity.model.entity.UnpaidActivityOrderEntity;
import org.sws.domain.activity.model.valobj.OrderTradeTypeVO;
import org.sws.domain.activity.service.quota.IRaffleActivityAccountQuotaService;
import org.sws.domain.behavior.event.SendRebateMessageEvent;
import org.sws.domain.behavior.strategy.RebateStrategy;

/**
 * @Author sws
 * @Date 2025/4/1 16:33
 * @description: 抽奖次数sku返利实现类
 */
@Slf4j
@Service(value = "sku")
@RequiredArgsConstructor
public class SkuRebateStrategy implements RebateStrategy {
    private final IRaffleActivityAccountQuotaService raffleActivityAccountQuotaService;
    @Override
    public String handleRebate(SendRebateMessageEvent.RebateMessage rebateMessage) {
        SkuRechargeEntity skuRechargeEntity = new SkuRechargeEntity();
        skuRechargeEntity.setUserId(rebateMessage.getUserId());
        skuRechargeEntity.setSku(Long.valueOf(rebateMessage.getRebateConfig()));
        skuRechargeEntity.setBizId(rebateMessage.getBizId());
        skuRechargeEntity.setOrderTradeType(OrderTradeTypeVO.rebate_no_pay_trade);
        UnpaidActivityOrderEntity unpaidActivityOrderEntity = raffleActivityAccountQuotaService.creatSkuRechargeOrder(skuRechargeEntity);
        return unpaidActivityOrderEntity.getOrderId();
    }
}
